﻿package game.account {
	
	import flash.display.StageQuality;
	
	import game.account.sockets.*;
	import game.objects.GameObject;
	import game.account.preview.*;
	import game.Config;
	import game.lang.Lang;
	import game.libs.Libs;
	import game.socket.Sockets;
	import game.network.Network;
	import game.music.Music;
	import game.account.friends.Friends;
	import game.objects.DynamicObject;
	import game.objects.DynamicElement;
	import game.account.header.Header;
	import game.account.sub.Sub;
	import game.account.shop.*;
	
	public class DataAccount extends GameObject {
		
		public var auto:SocketAuto;
		public var viewer:Preview;
		public var friends:Friends;
		public var header:Header;
		public var sub:Sub;
		
		
		public function inited():void {
			
			auto 			= new SocketAuto;
			viewer			= new Preview;
			viewer.param	= (config.quality == StageQuality.LOW) ? new PreviewLowObject : new PreviewObject;
			
			header			= new Header;
			sub				= new Sub;
			friends			= new Friends;
			
			addChild		( viewer );
			addChild		( sub );
			addChild		( header );
			addChild		( friends );
			
		}
		
		public function openShopCar():void {
			if (getChildByName(DynamicObject.SHOP_CAR)) return;
			
			var shop:ShopCar = new ShopCar;
			shop.addEventListener ( ShopCarEvent.SELECT, function (event:ShopCarEvent) { dispatchEvent (new ShopCarEvent(event.type, event.data)); });
			shop.name = DynamicObject.SHOP_CAR;
			addChild(shop);
			
		}
		
		public function openDonat():void {
			if (getChildByName(DynamicObject.SHOP_DONAT)) return;
			
			var shop:ShopDonat = new ShopDonat;
			shop.name = DynamicObject.SHOP_DONAT;
			addChild(shop);
		}
		
		
	}
	
}